package com.shareach.domain;

import java.util.Arrays;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;
import com.shareach.util.Globals;

/**
 * create time：2013-1-31 下午3:01:12
 * 
 * @author retryu
 * @since JDK 1.6
 * @version 1.0 description：
 */

@Document(collection = "bizActivityShop")
public class BizActivityShopDomain extends Entity {

	// 活动_id
	private Long activityId;

	// 银行 参见 来源网站 BaseSite
	private Long bank;

	// 银行卡种ID
	private Integer bankCardId;
	// 品牌名称
	private String brandName;

	// 商家名称
	private String name;

	// 全称
	private String orgName;

	// 商家地址
	private String addr;

	// 商家 如果未绑定，则为空，商家
	private Long shopId;

	// 电话集合
	private String[] tels;

	// 描述
	private String descr;
	// 折扣规则
	private String discountRule;

	// 打折的周几 如果没有表示不安周
	private Integer[] discountWeek;

	// 起始时间 同截止日期
	private Date start;

	// 截止时间 如果商户存在截止日期，则使用商户截止日期，否则使用活动表中的截止日期
	private Date end;

	private Long city;

	private String cityName;
	// 匹配时间
	private Date matchTime;

	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;
	@Transient
	private BaseShopDomain baseShop;

	// 状态
	private Integer status;

	public BaseShopDomain getBaseShop() {
		return baseShop;
	}

	public void setBaseShop(BaseShopDomain baseShop) {
		this.baseShop = baseShop;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public Date getMatchTime() {
		return matchTime;
	}

	public void setMatchTime(Date matchTime) {
		this.matchTime = matchTime;
	}

	public Long getActivityId() {
		return activityId;
	}

	public String getAddr() {
		return addr;
	}

	public Integer[] getDiscountWeek() {
		return discountWeek;
	}

	public void setDiscountWeek(Integer[] discountWeek) {
		this.discountWeek = discountWeek;
	}

	public Integer getBankCardId() {
		return bankCardId;
	}

	public String getBrandName() {
		return brandName;
	}

	public String getCityName() {
		return cityName;
	}

	public String getDescr() {
		return descr;
	}

	public String getDiscountRule() {
		return discountRule;
	}

	public Date getEnd() {
		return end;
	}

	public String getName() {
		return name;
	}

	public String getOrgName() {
		return orgName;
	}

	public Long getShopId() {
		return shopId;
	}

	public Date getStart() {
		return start;
	}

	public String[] getTels() {
		return tels;
	}

	public void setActivityId(Long activityId) {
		this.activityId = activityId;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public Long getBank() {
		return bank;
	}

	public void setBank(Long bank) {
		this.bank = bank;
	}

	public void setBankCardId(Integer bankCardId) {
		this.bankCardId = bankCardId;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public Long getCity() {
		return city;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public void setDescr(String descr) {
		this.descr = descr;
	}

	public void setDiscountRule(String discountRule) {
		this.discountRule = discountRule;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public void setTels(String[] tels) {
		this.tels = tels;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public BizActivityShopDomain compareTo(BizActivityShopDomain domain) {
		BizActivityShopDomain change = new BizActivityShopDomain();
		if (domain == null) {
			return change;
		}
		if (domain.getActivityId() != null) {
			if (this.activityId == null || !this.activityId.equals(domain.getActivityId())) {
				change.setActivityId(domain.getActivityId());
			}
		}
		if (domain.getBank() != null) {
			if (this.bank == null || !this.bank.equals(domain.getBank())) {
				change.setBank(domain.getBank());
			}
		}
		if (StringUtils.isNotEmpty(domain.getOrgName())) {
			if (this.orgName == null || !this.orgName.trim().equals(domain.getOrgName().trim())) {
				change.setOrgName(domain.getOrgName());
			}
		}
		if (domain.getShopId() != null) {
			if (this.shopId == null || !domain.getShopId().equals(this.shopId)) {
				change.setShopId(domain.getShopId());
			}
		}
		if (StringUtils.isNotEmpty(domain.getDescr())) {
			if (this.descr == null || !domain.getDescr().trim().equals(this.descr.trim())) {
				change.setDescr(domain.getDescr());
			}
		}
		if (domain.getDiscountWeek() != null && domain.getDiscountWeek().length > 0) {
			if (this.discountWeek == null || !Arrays.equals(this.discountWeek, domain.getDiscountWeek())) {
				change.setDiscountWeek(domain.getDiscountWeek());
			}
		}
		if (StringUtils.isNotEmpty(domain.getDiscountRule())) {
			if (this.discountRule == null || !this.discountRule.trim().equals(domain.getDiscountRule().trim())) {
				change.setDiscountRule(domain.getDiscountRule().trim());
			}
		}
		if (domain.getStart() != null) {
			if (!Globals.FORMAT_TYPE_A.format(this.start).equals(Globals.FORMAT_TYPE_A.format(domain.getStart()))) {
				change.setStart(domain.getStart());
			}
		}
		if (domain.getEnd() != null) {
			if (this.end == null
					|| !Globals.FORMAT_TYPE_A.format(this.end).equals(Globals.FORMAT_TYPE_A.format(domain.getEnd()))) {
				change.setEnd(domain.getEnd());
			}
		}
		if (domain.getStatus() != null) {
			if (null == this.status || !this.status.equals(domain.getStatus())) {
				change.setStatus(domain.getStatus());
			}
		}
		return change;
	}

}
